package com.content.management.domain.dto;

import com.content.management.domain.entity.BusPublishContent;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

import java.time.LocalDateTime;
import java.util.Objects;

/**
 * @author xinghu
 * @version 1.0
 * @date 2020/4/4 5:00 下午
 */
@Data
@Accessors(chain = true)
@ApiModel(value = "内容发布新增及修改提交数据", description = "内容发布新增及修改提交数据")
public class PublishContentDto {

	@ApiModelProperty(value = "主键id 存在即为修改不存在则为新增")
	private Long id;

	@ApiModelProperty(value = "发布状态：0：已发布；1：未发布")
	private Integer publishStatus;

	@ApiModelProperty(value = "内容主题")
	private String contentTopic;

	@ApiModelProperty(value = "发布的具体类容")
	private String content;

	@ApiModelProperty(value = "面向的发布人群")
	private String publishCrowd;

	@ApiModelProperty(value = "所属分类")
	private String classification;

	@ApiModelProperty(value = "发布类型 ：ALERT、公告；CONTENT 、内容")
	private String publishType;

	public BusPublishContent to() {
		BusPublishContent busPublishContent = new BusPublishContent();
		BeanUtils.copyProperties(this, busPublishContent);
		if (Objects.isNull(busPublishContent.getId())) {
			busPublishContent.setCreateTime(LocalDateTime.now());
		}
		busPublishContent.setPublishTime(LocalDateTime.now());
		busPublishContent.setUpdateTime(LocalDateTime.now());
		return busPublishContent;
	}
}
